using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 
using System.Web;
using System.Web.Security; 
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class viewDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label2.Text = "Logged in as: " + Context.User.Identity.Name;

        logoutButton.Visible = true;
        logoutButton.Text = "[Logout]";

        int CompId = Convert.ToInt32(Request.Params["CompId"]);

        if (Request.Params["CompId"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            Image1.ImageUrl = "logoView.aspx?CompId=" + CompId;
            Literal1.Text = load_data(CompId).ToString();
        }
    }

    public StringBuilder load_data(int comp_id) // Isolate to dbProcessor, dublicated in deleteEntry.aspx.cs
    {
        cmpEntry delCmp = new cmpEntry();
        
        delCmp.cmpGet(comp_id);

        StringBuilder sb = new StringBuilder();

        sb.Append("<TABLE border=1>");

        sb.Append("<TR>");
        sb.Append("<TD>Company: </TD>");
        sb.Append("<TD>" + delCmp.cmpName + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>Country: </TD>");
        sb.Append("<TD>" + delCmp.cmpCountry + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>City: </TD>");
        sb.Append("<TD>" + delCmp.cmpCity + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>Address: </TD>");
        sb.Append("<TD>" + delCmp.cmpAddress + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>E-mail: </TD>");
        sb.Append("<TD>" + delCmp.cmpEmail + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>Phone: </TD>");
        sb.Append("<TD>" + delCmp.cmpPhone + "</TD>");
        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>Fax: </TD>");
        sb.Append("<TD>" + delCmp.cmpFax + "</TD>");

        sb.Append("</TR>");

        sb.Append("<TR>");
        sb.Append("<TD>Web: </TD>");
        sb.Append("<TD>" + delCmp.cmpWebsite + "</TD>");
        sb.Append("</TR>");

        sb.Append("</TABLE>");

        return sb;
    }
    protected void btnLogout_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Response.Redirect("Default.aspx");
    }
    protected void btnClose(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx"); 
        
    }
}
